<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="main"/>
  <script type="text/javascript" src="${createLinkTo(dir: 'js/jquery', file: 'jquery-1.3.2.min.js')}"></script>
  <link rel="stylesheet" href="${createLinkTo(dir: 'facebox', file: 'facebox.css')}"/>
  <script type="text/javascript" src="${createLinkTo(dir: 'facebox', file: 'facebox.js')}"></script>

  <g:javascript>
        $(function() {
          $(".publish").click(function() {
              $(this).html('...');
              var it = this
              $.get($(this).attr('href'),{}, function(data) {
                  if (data=="1") {
                     $(it).html('取消发布');
                  } else if (data=="0") {
                      $(it).html('发布');
                  } else {
                      alert("错误。");
                      $(it).html('发布');
                  }
              });
              return false;
          });
          $('a[rel*=facebox]').facebox({
            loading_image : '${createLinkTo(dir: 'facebox', file: 'loading.gif')}',
            close_image   : '${createLinkTo(dir: 'facebox', file: 'closelabel.gif')}'
          });

        })
  </g:javascript>

  <title>Show Plan</title>
</head>
<body>
<div class="nav">
  <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}">Home</a></span>
  <span class="menuButton"><g:link class="list" action="list">Plan List</g:link></span>
  <span class="menuButton"><g:link class="create" action="create">New Plan</g:link></span>
</div>
<div class="body">
  <h1>Show Plan</h1>
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <div class="dialog">
    <table>
      <tbody>

      <tr class="prop">
        <td valign="top" class="name">Id:</td>

        <td valign="top" class="value">${fieldValue(bean: planInstance, field: 'id')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Description:</td>

        <td valign="top" class="value">${planInstance.description}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Plan Type:</td>

        <td valign="top" class="value">${fieldValue(bean: planInstance, field: 'planType')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Scheme:</td>

        <td valign="top" class="value">${fieldValue(bean: planInstance, field: 'scheme')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Date Created:</td>

        <td valign="top" class="value">${fieldValue(bean: planInstance, field: 'dateCreated')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">End With:</td>

        <td valign="top" class="value">${fieldValue(bean: planInstance, field: 'endWith')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Last Updated:</td>

        <td valign="top" class="value">${fieldValue(bean: planInstance, field: 'lastUpdated')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Name:</td>

        <td valign="top" class="value">${fieldValue(bean: planInstance, field: 'name')}</td>

      </tr>

      <tr class="prop">
        <td valign="top" class="name">Start With:</td>

        <td valign="top" class="value">${fieldValue(bean: planInstance, field: 'startWith')}</td>

      </tr>

      </tbody>
    </table>
  </div>
  <div class="buttons">
    <g:form>
      <input type="hidden" name="id" value="${planInstance?.id}"/>
      <span class="button"><g:actionSubmit class="edit" value="Edit"/></span>
      <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete"/></span>
      <g:link action="preview" id="${planInstance.id}" rel="facebox">预览</g:link>
      <g:if test="${!planInstance.published}">
        <g:link action="ajaxpublish" id="${planInstance.id}" class="publish">发布</g:link>
      </g:if>
      <g:else><g:link action="ajaxpublish" id="${planInstance.id}" class="publish">取消发布</g:link></g:else>

    </g:form>
  </div>
</div>
</body>
</html>
